<?php

session_start();

include "webmaster_connect.php";

$page_permission = 1;

include "webmaster_check_login.php";

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My account</title>

<style type="text/css">
body {
	background-image: url(../images/wood.jpg);
	background-repeat: repeat-x;
	margin: 0px;
	background-position: left top;
	background-attachment: fixed;
	background-color: #000000;
	padding-top: 0px;
	padding-right: 0px;
	padding-bottom: 0px;
	padding-left: 0px;
}
</style>
<link href="../css/webmaster_account.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div id="page_container">

<?php 

include "../admin_files/webmaster_header.php";
include "../admin_files/webmaster_navigation.php" 

?>

	<div id="login_container">

	<?php

	$webmaster_id = $_SESSION['webmasterid'];
	$query = "SELECT * FROM webmaster_users WHERE id = $webmaster_id";
	$result = mysql_query($query);
	$userData = mysql_fetch_array($result, MYSQL_ASSOC);
	$webmaster_username = $userData['username'];

	$alerts = array();

	//New messages

	$query = "SELECT * FROM customer_messages WHERE message_status = 'New'";
	$result = mysql_query($query);
	$new_messages = mysql_num_rows($result);
	if  ($new_messages >=1) 

		{
		array_push($alerts, "<label><a href='webmaster_customer_messages.php'>View</a>New messages:<b> ".$new_messages."</b></label>");
		}
	
	//End

	//New sell requests

	$query = "SELECT * FROM customer_sell_requests WHERE request_status = 'New'";
	$result = mysql_query($query);
	$new_sell_requests = mysql_num_rows($result);
	if  ($new_sell_requests >=1) 

		{
		array_push($alerts, "<label><a href='webmaster_view_sell_requests.php'>View</a>New sell requests:<b> ".$new_sell_requests."</b>			</label>");
		}
	
	//End

	//New feedback

	$query = "SELECT * FROM customer_feedback WHERE feedback_status = 'New'";
	$result = mysql_query($query);
	$num_feedback = mysql_num_rows($result);
	if  ($num_feedback >=1) 
	
		{
		array_push($alerts, "<label>New feedback:<b> ".$num_feedback."</b></label>");
		}
		
	//End
	
	?>

	<h1><b>Logged in as: </b><?php  echo $webmaster_username ?></h1>

	<?php

	//Todays sales
	
	$today = date("Y-m-d");
	$query = "SELECT * FROM cash_payments";
	$result = mysql_query($query);
	$todays_cash_sales = mysql_num_rows($result);

	$today = date("Y-m-d");
	$query = "SELECT * FROM paypal_payments";
	$result = mysql_query($query);
	$todays_paypal_sales = mysql_num_rows($result);

	$total_sales = $todays_cash_sales + $todays_paypal_sales;	

	echo "<label>Total website sales:<b> ".$total_sales."</b></label><br /><br />";
	echo "<label><i>Paypal sales:</i><b> ".$todays_paypal_sales."</b></label><br />";
	echo "<label><i>Cash  sales:</i><b> ".$todays_cash_sales."</b></label>";
	
	//End

	?>

	<h1>Site information</h1>

	<?php

	//Todays searches

	$today = date("Y-m-d");
	$query = "SELECT * FROM search_history WHERE search_date = '$today'";
	$result = mysql_query($query);
	$todays_searches = mysql_num_rows($result);
	echo "<label>Todays searches:<b> ".$todays_searches."</b></label>";

	//End

	echo "<br /><br />";

	//Active customer alerts

	$query = "SELECT * FROM customer_alerts WHERE status = 'Active'";
	$result = mysql_query($query);
	$num_alerts = mysql_num_rows($result);
	echo "<label>Active customer alerts:<b> ".$num_alerts."</b></label>";

	//End

	?>

	<h1>Alerts</h1>
	
	<?php

	foreach ($alerts as $value) 

		{
		echo $value."<br /><br />" ;
		}
	
	?>

	</div>
	<!--login_container-->

</div> 
<!--page_container-->

</body>
</html>